package com.beiben.ability.people.service.impl;

import com.beiben.ability.people.domain.Record;
import com.beiben.ability.people.mapper.DetailsMapper;
import com.beiben.ability.people.mapper.RecordMapper;
import com.beiben.ability.people.service.IRecordService;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 考试记录Service业务层处理
 *
 * @author dulei
 * @date 2020-08-26
 */
@Service
public class RecordServiceImpl implements IRecordService {

    @Autowired
    private RecordMapper recordMapper;

    @Autowired
    private DetailsMapper detailsMapper;

    /**
     * 查询考试记录
     *
     * @param recordId 考试记录ID
     * @return 考试记录
     */
    @Override
    public Record selectRecordById(Long recordId) {
        return recordMapper.selectRecordById(recordId);
    }

    /**
     * 查询考试记录列表
     *
     * @param record 考试记录
     * @return 考试记录
     */
    @Override
    @DataScope(deptAlias = "sd")
    public List<Record> selectRecordList(Record record) {
        return recordMapper.selectRecordList(record);
    }

    @Override
    public List<Record> selectRecordExcelList(Record record) {
        return recordMapper.selectRecordExcelList(record);
    }

    /**
     * 新增考试记录
     *
     * @param record 考试记录
     * @return 结果
     */
    @Override
    public int insertRecord(Record record) {
        record.setCreateTime(DateUtils.getNowDate());
        return recordMapper.insertRecord(record);
    }




    /**
     * 修改考试记录
     *
     * @param record 考试记录
     * @return 结果
     */
    @Override

    public int updateRecord(Record record) {
        record.setUpdateTime(DateUtils.getNowDate());
        return recordMapper.updateRecord(record);
    }

    /**
     * 批量删除考试记录
     *
     * @param recordIds 需要删除的考试记录ID
     * @return 结果
     */
    @Override
    public int deleteRecordByIds(Long[] recordIds) {
        detailsMapper.deleteDetailsByRecordIds(recordIds);
        return recordMapper.deleteRecordByIds(recordIds);
    }

    /**
     * 删除考试记录信息
     *
     * @param recordId 考试记录ID
     * @return 结果
     */
    @Override
    public int deleteRecordById(Long recordId) {
        detailsMapper.deleteDetailsByRecordId(recordId);
        return recordMapper.deleteRecordById(recordId);
    }
}
